package com.easy.service.impl;

import com.easy.annotation.LogMethod;
import com.easy.bean.Sizes;
import com.easy.mapper.SizesDao;
import com.easy.service.SizesService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SizesServiceImpl implements SizesService {
@Autowired
    SizesDao sizesDao;

@LogMethod(serviceName = "添加",recordParam = true,recordReturn = true)
    @Override
    public Sizes add(Sizes sizes) {
        sizesDao.add(sizes);
        return sizesDao.one(sizes.getId());
    }

    @LogMethod(serviceName = "删除",recordParam = true,recordReturn = true)
    @Override
    public int del(Integer id) {
        return sizesDao.del(id);
    }

    @LogMethod(serviceName = "修改",recordParam = true,recordReturn = true)
    @Override
    public Sizes edit(Sizes sizes) {
        sizesDao.edit(sizes);
        return sizesDao.one(sizes.getId());
    }

    @LogMethod(serviceName = "查询",recordParam = true,recordReturn = true)
    @Override
    public List<Sizes> all(Sizes sizes) {
        return sizesDao.all(sizes);

    }

    @LogMethod(serviceName = "查询",recordParam = true,recordReturn = true)
    @Override
    public Sizes one(Integer id) {
        return sizesDao.one(id);
    }

    @LogMethod(serviceName = "分页查询",recordParam = true,recordReturn = true)
    @Override
    public void page(Page page, Sizes sizes) {
        int count =sizesDao.pageCount(sizes);
        Object data=sizesDao.page(page, sizes);
        page.setCount(count);
        page.setData(data);
    }
}
